const app = new getApp();

Page({
  listClick:function(event){
    let data_url = event.currentTarget.dataset.url;
    wx.navigateTo({ url: '/pages/' + data_url});
    //wx.redirectTo({ url: '/pages/' + data_url});
  },
  /**
   * 页面的初始数据
   */
  data: {
    prompt: '',
    Base: '',
    member_info: {},
    unpaidOrder: 0, //待支付
    shipmentPendingOrder: 0, //待发货
    goodsNotReceivedOrder: 0, //待收货
    refundOrder: 0 //退款
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    let base = getApp().globalData.siteBaseUrl;
    
    that.setData({
      Base: base
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let that = this;
    let member_info = that.data.member_info;

    app.sendRequest({
      url: 'api.php?s=member/getMemberDetail',
      data: {},
      header: {
        'content-type': 'application/json' // 默认值
      },
      method: "POST",
      success: function (res) {
        let code = res.code;
        if (code == 0) {
          that.setData({
            member_info: res.data,
          })
        }
        console.log(res)
        console.log(res.data)
      }
    })

    app.sendRequest({
      url: 'api.php?s=member/memberIndex',
      data: {},
      header: {
        'content-type': 'application/json' // 默认值
      },
      method: "POST",
      success: function (res) {
        let code = res.code;
        let data = res.data;
        if (code == 0) {
          that.setData({
            unpaidOrder: data.unpaidOrder,
            shipmentPendingOrder: data.shipmentPendingOrder,
            goodsNotReceivedOrder: data.goodsNotReceivedOrder,
            refundOrder: data.refundOrder
          })
        }
        console.log(res)
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})